package com.neusoft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neusoft.model.OrderSearch;
import com.neusoft.po.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 订单详情DAO
 *
 * @author Lucifer
 * @since 2021/5/16 8:04
 */
@Repository
public interface OrderMapper extends BaseMapper<Order> {

    List<Order> list(OrderSearch orderSearch);

    @Update("update `order` set status = '1' where id = #{id}")
    Integer submit(@Param("id") Integer id);

    @Update("update `order` set status = '2' where id = #{id}")
    Integer pay(@Param("id") Integer id);

    @Select("select a.order_id from order_item_rel a inner join order b on a.order_id = b.order_id " +
            "where b.status = '0' and a.item_id = #{item_id}")
    List<Integer> selectNotSumbit(@Param("item_id") Integer item_id);

    @Update("update order set price = #{price} where order_id = #{order_id}")
    Integer updatePrice(@Param("price") Double price, @Param("order_id") Integer order_id);
}
